package org.mall.modules.message.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mall.modules.message.entity.AppMessage;
import org.mall.modules.message.entity.AppMsgUserParams;

import java.util.Collection;
import java.util.List;

/***
 *@author yinxucun
 *@date 2019-11-12 17:07 
 */
@Mapper
public interface AppMessageMapper extends BaseMapper<AppMessage> {

    IPage<AppMessage> getPersonalMessageList(Page page, @Param("userId") String userId);

    IPage<AppMessage> getPersonalNoReadMessageList(Page page, String userId);
    @Update("update sp_app_message set is_delete = 1 where id  = #{id}")
    boolean deleteOne (@Param("id")String id);

    @Update("update sp_app_message set is_delete =   1 where receiver_id = #{id}  ")
    boolean deletAllMessage(@Param("id") String userId);

    @Select("select * from  sp_app_msg_user_params where user_id = #{id} limit  1;")
    AppMsgUserParams getOneMsgParams(@Param("id") String userId);

    IPage<AppMessage> getMallNoticeList(Page page, @Param("type") Integer type,@Param("id") Integer id);

    @Select("select * from app_message where receiver = #{id} order by id desc ")
    IPage<AppMessage> getPageListOfMessage(Page page, @Param("id") String userId);

    @Select("select * from app_message where receiver= #{userId} and id >{id} order by id desc")
    List<AppMessage> getNewMessageListById(@Param("userId")String userId, @Param("id") Long id);
}
